package com.hq.door.dto;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import com.hq.door.pojo.TOutRequest;

public class OutRequestDto {
	public static OutRequest writeMajor(TOutRequest tOutRequest){
		OutRequest outRequest = new OutRequest();
	    if (tOutRequest != null){
	    	outRequest.setId(tOutRequest.getId());
	    	outRequest.setTeachername(tOutRequest.getTTeacher().getName());
	    	outRequest.setStudentname(tOutRequest.getTStudent().getName());
	    	outRequest.setRequestReason(tOutRequest.getRequestReason());
	    	outRequest.setRejectReason(tOutRequest.getRejectReason());
	    	outRequest.setStartTime(tOutRequest.getStartTime());
	    	outRequest.setEndTime(tOutRequest.getEndTime());
	    	outRequest.setAuthStatus(tOutRequest.getAuthStatus());
	    	outRequest.setRequestTime(tOutRequest.getRequestTime());
	    	outRequest.setAuthTime(tOutRequest.getAuthTime());
	    	outRequest.setIsAgent(tOutRequest.getIsAgent());
	    	outRequest.setModifiedTime(tOutRequest.getModifiedTime());
	    	outRequest.setModifiedBy(tOutRequest.getModifiedBy());
	    }
	    return outRequest;
    }
	
	
	public static OutRequest[] writeMajor(Collection teachers){
		List list = new ArrayList();
		if (teachers != null){
			Iterator iterator = teachers.iterator();
            while (iterator.hasNext())
            {
                list.add(writeMajor((TOutRequest) iterator.next()));
            }
		}
		Teacher[] array = new Teacher[list.size()]; 
		return (OutRequest[]) list.toArray(array);
	}

	public static TOutRequest readMajor(OutRequest outRequest){
		TOutRequest tOutRequest = new TOutRequest();
	    if (tOutRequest != null){
	    	tOutRequest.setId(outRequest.getId());
	    	tOutRequest.setRequestReason(outRequest.getRequestReason());
	    	tOutRequest.setRejectReason(outRequest.getRejectReason());
	    	tOutRequest.setStartTime(outRequest.getStartTime());
	    	tOutRequest.setEndTime(outRequest.getEndTime());
	    	tOutRequest.setAuthStatus(outRequest.getAuthStatus());
	    	tOutRequest.setRequestTime(outRequest.getRequestTime());
	    	tOutRequest.setAuthTime(outRequest.getAuthTime());
	    	tOutRequest.setIsAgent(outRequest.getIsAgent());
	    	tOutRequest.setModifiedTime(outRequest.getModifiedTime());
	    	tOutRequest.setModifiedBy(outRequest.getModifiedBy());
	    	
	    }
	    return tOutRequest;
    }

}
